@extends('admin.layouts.layout')
@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h5>角色管理</h5>
            </div>
            <div class="ibox-content">
                <a class="menuid btn btn-primary btn-sm" href="javascript:location.reload();"><i
                            class="fa fa-refresh"></i> 刷新</a>
                <a href="{{route('roles.create')}}" link-url="javascript:void(0)">
                    <button class="btn btn-primary btn-sm" type="button"><i class="fa fa-plus-circle"></i> 添加角色</button>
                </a>
                <form class="form-common" action="{{ route('roles.index') }}"
                      method="get">
                    {{ csrf_field() }}
                    <input type="hidden" name="page_size" value="{{$reqPageSize}}"/>
                </form>
                <table class="table table-striped table-bordered table-hover m-t-md">
                    <thead>
                    <tr>
                        <th class="text-center" width="100">ID</th>
                        <th>角色名称</th>
                        <th>角色描述</th>
                        <th class="text-center" width="100">排序</th>
                        <th class="text-center" width="100">状态</th>
                        <th class="text-center" width="300">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($roles as $key => $item)
                        <tr>
                            <td class="text-center">{{$item->id}}</td>
                            <td>{{$item->name}}</td>
                            <td>{{$item->remark}}</td>
                            <td class="text-center">{{$item->order}}</td>
                            <td class="text-center">
                                @if($item->status == 1)
                                    <span class="text-navy">启用</span>
                                @else
                                    <span class="text-danger">禁用</span>
                                @endif
                            </td>
                            <td class="text-center">
                                <div class="btn-group">
                                    <a href="{{route('roles.access',$item->id)}}">
                                        <button class="btn btn-primary btn-xs" type="button"><i class="fa fa-paste"></i>
                                            权限设置
                                        </button>
                                    </a>
                                    <a href="{{route('roles.edit',$item->id)}}">
                                        <button class="btn btn-primary btn-xs" type="button"><i class="fa fa-paste"></i>
                                            修改
                                        </button>
                                    </a>
                                    <form class="form-common" action="{{ route('roles.destroy', $item->id) }}"
                                          method="post">
                                        {{ csrf_field() }}
                                        {{ method_field('DELETE') }}
                                        <button class="btn btn-danger btn-xs" type="submit"
                                                onclick="if (!confirm('确定要删除吗?删除后无法撤销!'))return false;"><i
                                                    class="fa fa-trash-o"></i> 删除
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <div class="pull-left pagination m-t-no">
                    @include('widget.page',['reqPageSize'=>$reqPageSize])
                </div>
                <div class="pull-right pagination m-t-no">
                    <div class="text-center">
                        <?php
                        if (count($roles) > 0) {
                            echo $roles->appends(
                                [
                                    'page_size' => app('request')->input('page_size'),
                                ])->links();
                        }
                        ?>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
@endsection
@section('js')
    <script src="{{loadEdition('/js/global.js')}}"></script>
@stop